import sys
import re
from loguru import logger

logger.remove()
logger.add(sys.stdout, format="<lvl>{message}</lvl>")


class Logger:
    mentioned_email_list = []
    content = ''

    def addList(self, text):
        email_list = re.findall(r"([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)", text)
        if email_list:
            for email in email_list:
                self.mentioned_email_list.append(email)

    def PRINTI(self, text):
        logger.info(text)
        self.content = self.content + '\n' + text
        self.addList(text)

    def PRINTE(self, text):
        logger.error(text)
        self.content = self.content + '\n' + text
        self.addList(text)

    def PRINTS(self, text):
        logger.success(text)
        self.content = self.content + '\n' + text
        self.addList(text)

    def PRINTD(self, text):
        logger.debug(text)
        self.content = self.content + '\n' + text
        self.addList(text)


L = Logger()


def PRINTI(text):
    L.PRINTI(text)


def PRINTE(text):
    L.PRINTE(text)


def PRINTS(text):
    L.PRINTS(text)


def PRINTD(text):
    L.PRINTD(text)
